<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Cache-Control" content="max-age=60">
    <meta http-equiv="Cache-Control" content="no-siteapp">
    <meta http-equiv="Cache-Control" content="no-transform">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
    <link th:href="@{/static/img/favicon.png}" rel="apple-touch-icon-precomposed">
    <link th:href="@{/static/img/favicon.png}" rel="shortcut icon" type="image/ico">
    <link th:href="@{/static/css/style.css}" rel="stylesheet" type="text/css">
    <script th:src="@{/static/plugin/jquery/jquery-3.3.1.js}"></script>
    <title>用户注册</title>
</head>
<body class="fed-min-width">
<!--nav-->
<div th:replace="nav::nav"></div>
<div class="fed-tabr-info fed-back-whits fed-min-width fed-line-top fed-hide-sm" style="display: block;">
    <ul class="fed-part-rows">
        <li class="fed-text-center"><a href="/"><i class="fed-icon-font fed-icon-shouye"></i><span class="fed-font-xii">首页</span></a></li>
        <li class="fed-text-center"><a href="http://www.shuyouge.cc"><i class="fed-icon-font fed-icon-zixun"></i><span class="fed-font-xii">小说</span></a></li>
        <li class="fed-text-center"><a href="/index.php/gbook/index.html"><i class="fed-icon-font fed-icon-liuyan"></i><span class="fed-font-xii">求片</span></a></li>
        <li class="fed-text-center"><a href="/index.php/topic/index.html"><i class="fed-icon-font fed-icon-zhuanti"></i><span class="fed-font-xii">专题</span></a></li>
        <li class="fed-text-center"><a class="fed-text-green" href="/index.php/user/login.html"><i class="fed-icon-font fed-icon-yonghu"></i><span class="fed-font-xii">我的</span></a></li>
    </ul>
</div>
<div class="fed-main-info fed-min-width">
    <div class="fed-part-case">

        <div class="fed-part-layout fed-back-whits fed-part-height" style="height: 504px;">
            <div class="fed-user-login fed-part-core">
                <div class="fed-list-head fed-part-rows fed-padding">
                    <h2 class="fed-font-xvii fed-text-center">用户注册</h2>
                </div>
                <form class="fed-user-form fed-user-width fed-part-rows" action="">
                    <input class="fed-user-text fed-col-xs12" type="text" name="username" placeholder="请输入账号">
                    <input class="fed-user-text fed-col-xs12" type="password" name="password" placeholder="请输入密码" maxlength="20">
                    <input class="fed-user-text fed-col-xs12" type="password" name="password2" placeholder="再次输入密码" maxlength="20">
                    <input class="fed-user-text fed-col-xs8" type="tel" name="verify" placeholder="请输入验证码" maxlength="4">
                    <img class="fed-user-code fed-user-text fed-col-xs4" height="45" th:src="@{/resource/auth}" onclick="this.src=this.src+'?'" title="看不清楚? 换一张！">
                    <span class="fed-user-tips fed-text-gules fed-padding-v fed-visible fed-col-xs12">　</span>
                    <a class="fed-subm-regis fed-user-submit fed-rims-info fed-btns-info fed-btns-green fed-col-xs12">注册</a>
                    <a class="fed-padding fed-col-xs3 fed-text-left" th:href="@{/login}">立即登录</a>
                    <a class="fed-padding fed-col-xs6 fed-text-center" href="javascript:;">&nbsp;</a>
                    <!--<a class="fed-padding fed-col-xs3 fed-text-right" th:href="@{/user/forget}">忘记密码</a>-->
                </form>
            </div>
        </div>
    </div>
</div>
<!--footer-->
<div th:replace="footer::footer"></div>
<script th:inline="javascript">
    var context=/*[[@{/}]]*/'';
    var ctx=context=="\/"?"":context;
    $(function () {
        //验证用户名
        $("input[name=username]").blur(function () {
            var username=$(this).val();
            $.ajax({
                "url":ctx+"/user/check",
                "type":"get",
                "data":{"username":username},
                success:function (data) {
                    if(data.code==1){
                        $(".fed-user-tips").html(data.msg);
                        $("input[name=username]").focus();
                    }else{
                        $(".fed-user-tips").html("　");
                    }
                }
            });
        });

        //注册
        $(".fed-subm-regis").click(function () {
            var flag=true;
            var inputs=$(".fed-user-form input");
            $.each(inputs,function (index,input) {
               if($(input).val()==""){
                   flag=false;
               }
            });
            if(flag==false){
                $(".fed-user-tips").html("各项不能为空");
            }else{
                $.ajax({
                    "url":ctx+"/user/register",
                    "type":"post",
                    "data":$(".fed-user-form").serialize(),
                    success:function (data) {
                        if(data.code==0){
                            $(".fed-user-tips").html("注册成功");
                            location.href=ctx+"/login";
                        }else{
                            $(".fed-user-tips").html(data.msg);
                            $(".fed-user-code").trigger("click");
                        }
                    }
                });
            }
        });
    });
</script>
</body>
</html>